package com.coderman.business.service.imp;

import com.coderman.business.mapper.ObtainEmpMapper;
import com.coderman.business.service.IObtainEmpService;
import com.coderman.business.service.base.AbstractServiceImpl;
import com.coderman.common.model.student.ObtainEmp;
import com.coderman.common.vo.system.PageVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;


@Service
public class ObtainEmpServiceImpl extends AbstractServiceImpl<ObtainEmpMapper, ObtainEmp, Integer> implements IObtainEmpService {

    @Autowired
    private ObtainEmpMapper obtainEmpMapper;
    @Override
    public PageVO<ObtainEmp> findobtainEmpList(Integer pageNum, Integer pageSize, ObtainEmp obtainEmp) {
        //已经拥有的
        PageHelper.startPage(pageNum,pageSize);
        Example o = new Example(ObtainEmp.class);
        Integer examtype = obtainEmp.getObtainempstatus();
        //Integer clsStatus = classVo.getClsstatus();
        Example.Criteria criteria = o.createCriteria();
        if(examtype!=null){
            criteria.andEqualTo("obtainempstatus",examtype);
        }

        List<ObtainEmp> classList= obtainEmpMapper.selectByParams(obtainEmp);
        PageInfo<ObtainEmp> info=new PageInfo<>(classList);
        return new PageVO<>(info.getTotal(),classList);
    }

    @Override
    public List<ObtainEmp> findAll() {
        return obtainEmpMapper.selectAll();
    }

    @Override
    public void add(ObtainEmp obtainEmp) {
        obtainEmpMapper.insert(obtainEmp);
    }

    @Override
    public ObtainEmp edit(Integer id) {
        return obtainEmpMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update( ObtainEmp obtainEmp) {
        obtainEmpMapper.updateByPrimaryKey(obtainEmp);
    }
}
